//
//  PostAddLocationCellData.m
//  CKApp
//
//  Created by CC on 2020/9/19.
//  Copyright © 2020 This Moment. All rights reserved.
//

#import "PostAddLocationCellData.h"
#import "PostAddLocationCell.h"

@implementation PostAddLocationCellData

+ (instancetype)cellDataWithTitle:(NSString*)locationTitle
            selectLocationHandler:(OnClickedHandler)selectLocationHandler
             clearLocationHandler:(OnClickedHandler)clearLocationHandler {
  PostAddLocationCellData* cellData = [[PostAddLocationCellData alloc] init];
  cellData.locationTitle = locationTitle;
  cellData.selectLocationHandler = selectLocationHandler;
  cellData.clearLocationHandler = clearLocationHandler;
  return cellData;
}

- (void)refreshCell:(__kindof PostAddLocationCell *)cell {
  [super refreshCell:cell];
  if (self.locationTitle.length > 0) {
    cell.contentLabel.text = self.locationTitle;
    [cell.clearButton setHidden:NO];
  } else {
    cell.contentLabel.text = @"添加地理位置";
    [cell.clearButton setHidden:YES];
  }
  cell.selectLocationHandler = self.selectLocationHandler;
  cell.clearLocationHandler = self.clearLocationHandler;
}

@end
